﻿namespace c__study_2_22
{
    class Student
    {
        public string name;
        public string sex;
        public int age;
        public int CSharp成绩;
        public int Unity成绩;

        public int Age
        {
            get
            {

                return age - 5;
            }
            set
            {
                if (value > 0 && value <= 150)
                    age = value + 5;
                else
                {
                    Console.WriteLine("请输入正确的年龄（1~150）");
                    age = 5;
                }
            }
        }
        public int Unity
        {
            get
            {
                return Unity成绩;
            }
            set
            {
                if (value > 0 && value <= 100)
                    Unity成绩 = value;
                else
                    Console.WriteLine("成绩区间(1-100)不对");
            }
        }
        public void Say()
        {
            Console.WriteLine("我叫{0},{1}岁，unity的成绩是{2}",name,Age,Unity);
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
          Student s1 = new Student();
            s1.name = "阿斯顿";
            s1.Age = 24;
            s1.Unity = 10;
            s1.Say();
        }
    }
}
